package com.lucker.service.caipiaomisstype;

import java.math.BigDecimal;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.lucker.ds.mapper.BaseCustomMapper;
import com.lucker.ds.model.CaiPiao;
import com.lucker.ds.model.CaiPiaoMissType;
import com.lucker.ds.model.CustomCaiPiaoMissType;
import com.lucker.service.BaseServiceImpl;
import com.lucker.service.caipiao.CaiPiaoService;

@Service
public class CaiPiaoMissTypeServiceImpl extends BaseServiceImpl<CaiPiaoMissType, CustomCaiPiaoMissType, Long> implements CaiPiaoMissTypeService {

	@Autowired
	CaiPiaoService caiPiaoService;
	
	
	@Override
	public BaseCustomMapper<CustomCaiPiaoMissType, Long> getCustomMapper() {
		return null;
	}
	
	
	
	public void initMissTypeList() {
		
		CaiPiaoMissType initQuery = new CaiPiaoMissType();
		initQuery.setCaiTypeId(8888888L);
		CaiPiao query = new CaiPiao();
		query.orderById(true);
		List<CaiPiao> list = caiPiaoService.queryAll(query);
		for(CaiPiao cp : list) {
			int caiId = cp.getCaiId();
			String typeId= cp.getCaiTypeId();
			List<CaiPiaoMissType> missList = queryAll(initQuery);
			for(CaiPiaoMissType ct : missList) {
				ct.setId(null);
				ct.setCaiId(Long.valueOf(caiId));
				ct.setCaiTypeId(Long.valueOf(typeId));
				BigDecimal num = new BigDecimal(1);
				BigDecimal _probability = num.divide(ct.getTheoryCycle(), 6 , BigDecimal.ROUND_HALF_UP);
				ct.setProbability(_probability);
				add(ct, false);
			}
			getLOGGER().error("完成了一个省的初始化................................." + caiId);
		}
	}

}
